<%@ page language="java" import="java.util.*"
	contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.control.UserControl"%>
<%@ page import="com.control.CalcuControl"%>
<%@ page import="com.model.User"%>
<%@ page import="com.model.Calcu"%>
<%@ page import="com.util.PageResultSet"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>成绩显示</title>
	</head>
	<body>
		<%
			request.setCharacterEncoding("UTF-8");
			String ToolBar = "";
	    	int curPage = 1;
		%>
		<table width="98%" border="0" align="center">
			<tr>
				<td></td>
			</tr>
			<tr>
				<td></td>
			</tr>
			<tr>
				<td>
					<fieldset>
						<legend>   
							统计优秀学生</legend>
					<form action="out_good_student.jsp" name="form1" method="post"><br><table width="60%" border="0" align="center" cellspacing="0"
								cellpadding="0">
								<tr align="center">
									<td align="right">&nbsp; 
										 <input type="submit" value="导出优秀学生" />
									</td>
								</tr>
								<tr>
									<td>
										<table border="1" width="99%" align="center" cellpadding="0"
											cellspacing="1" class="resultTable">
											<tr>
												<td width="2%" height="25" align="center" bgcolor="#D9F0FF">  
													学号</td>
												<td width="2%" height="25" align="center" bgcolor="#D9F0FF">  
													姓名</td>
												<td width="4%" height="25" align="center" bgcolor="#D9F0FF">  
												           性别<br></td>
												<td width="2%" height="25" align="center" bgcolor="#D9F0FF"> 
													平均分</td>
								</tr>
								
								<%
									CalcuControl cc = new CalcuControl();
									UserControl uc = new UserControl();
									ArrayList<Calcu> list = new ArrayList<Calcu>();
									list = cc.CalcuTop();
									if(request.getParameter("cur_page")!= null) {
										curPage = Integer.parseInt(request.getParameter("cur_page")); 
									}
									PageResultSet p = new PageResultSet(list,curPage);
									ArrayList<Calcu> nowlist = new ArrayList<Calcu>();
									nowlist = (ArrayList<Calcu>)p.getData();
									for(int i=0; i<nowlist.size(); i++) {
										Calcu calcu = nowlist.get(i);
										int student_id = calcu.getStudent_id();
										User user = uc.getUser(student_id);
								%>
								 	<tr>
        								<td height="25" align="center"><%=user.getUsername()%></td>
 										<td height="25" align="center"><%=user.getName()%></td>
 										<td height="25" align="center"><%=user.getSex()%></td>
 										<td height="25" align="center"><%=calcu.getAvg()%></td>
 									</tr>
   									<%}
   										
										String fileName = "good_student.jsp";
										ToolBar = p.getToolBar(fileName);
									%>
							</table>
							<%=ToolBar %>
							</td>
							</tr>
							</table><br></form>
					</fieldset>
				</td>
			</tr>
		</table>
	</body>
</html>
